package com.html;

import java.io.IOException;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

public class YoukuJsoup {

	public YoukuJsoup() {

	}

	public String getFocusVideoURL(Document doc) {
		String tempUrl;
		Elements content = doc.getElementsByClass("focus_info");
		tempUrl = content.get(0).getElementsByClass("cap").get(0).children()
				.get(0).children().attr("href");
		if (tempUrl.contains("news.youku")) {
			String newsUrl = "";
			try {
				Document doc2 = Jsoup.connect(tempUrl).timeout(60000).get();
				newsUrl = doc2.getElementsByClass("player").get(0).children()
						.get(0).children().attr("href");
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			return newsUrl;
		} else {
			return tempUrl;
		}

	}

}
